package com.ijianji.module_play_video.utils

import android.text.TextUtils
import com.blankj.utilcode.util.LogUtils
import com.danikula.videocache.file.FileNameGenerator

/**
 *===========================================================
 * author：songpeng on 12/21/20 09:46
 * email：fenghuajueli@gmail.com
 *===========================================================
 * 视频缓存地址处理工具
 */
class VideoCacheFileNameGenerator : FileNameGenerator {


    override fun generate(url: String): String {
        if (TextUtils.isEmpty(url)) {
            return url
        }
        val index: Int = url.indexOf("?")
        if (index < 0) {
            return url
        }
        try {
            val subStr: String = url.substring(index + 1)
            if (subStr.contains("auth_key=")) {
                return url.substring(0, index)
            }
        } catch (e: Exception) {
            e.printStackTrace()
        }
        return url;
    }


}